10 int cache
[1001][1001];
13 if (cache
[i
][j
] != -1){
16 if (j
< i
) swap(i
, j
);
18 for (int k
=0; k
<p
.size()-1; ++k
){
19 if (p
[k
] <= i
&& i
<= p
[k
+1] &&
20 p
[k
] <= j
&& j
<= p
[k
+1]){
21 return cache
[i
][j
] = 0;
26 for (int k
=0; k
<p
.size(); ++k
){
27 if (i
< p
[k
] && p
[k
] < j
){
28 int q
= j
- i
+ f(i
, p
[k
]) + f(p
[k
], j
);
34 return cache
[i
][j
] = min
;
40 while (cin
>> l
&& l
> 0){
46 for (int i
=1; i
<=n
; ++i
){
49 for (int i
=0;i
<=n
+1;++i
){
50 for (int j
=i
;j
<=n
+1;++j
){
54 cout
<< "The minimum cutting is " << f(0, l
) << ".\n";